package org.dr.st_docker.proxy.dynamic;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

/**
 * jdk动态代理处理器
 * InvocationHandler接口主要是织入横切逻辑实现增强，并将切点和增强融合在一起形成切面
 * 切面类
  */

public class ServiceInvocationHandler implements InvocationHandler {
    private Object target;

    public ServiceInvocationHandler(Object target) {
        this.target = target;
    }
//所有通过动态代理实现的方法全部通过invoke方法调
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        System.out.println(" Dynamic Proxy: Before operation");
        Object result = method.invoke(target, args);
        System.out.println("Dynamic Proxy: After operation");
        return result;
    }
}
